
[dbo].[asi_PrcProductClassDiscounts]
CREATE PROCEDURE [dbo].[asi_PrcProductClassDiscounts]
@priceSheetVersionKey uniqueidentifier
AS
BEGIN
SELECT dr.RuleKey, rf.ValueOne AS 'ProductClassName',
pbr.PriceBasisDesc, dr.IsPercent, dr.Adjustment
FROM PriceSheetDiscount psd
INNER JOIN DiscountRule dr ON psd.DiscountRuleKey = dr.RuleKey
INNER JOIN RuleMain rm ON dr.RuleKey = rm.RuleKey
INNER JOIN RuleCriterion rc ON rm.RuleKey = rc.RuleKey
INNER JOIN RuleFilter rf ON rc.RuleCriterionKey = rf.RuleCriterionKey
INNER JOIN ComparisonRef cr ON rf.ComparisonCode = cr.ComparisonCode
INNER JOIN PriceBasisRef pbr ON dr.PriceBasisCode = pbr.PriceBasisCode
WHERE psd.PriceSheetVersionKey = @priceSheetVersionKey
AND rc.ObjectName = 'ProductClass'
AND rf.PropertyName = 'Name'
AND cr.ComparisonDesc = 'Equal'
ORDER BY ProductClassName, PriceBasisDesc
END
GO